package com.naizhuai.ui.testunit;

import android.Manifest;

import com.naizhuai.Model.db.user.PersonUserBean;
import com.naizhuai.R;
import com.naizhuai.util.ConstantsPersonResources;
import com.naizhuai.ui.BaseActivity;
import com.naizhuai.util.NetWorkUtils;
import com.naizhuai.util.PacageUtils;
import com.naizhuai.util.PermissionRequest;
import com.naizhuai.util.SharedPreferenceUtil;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;



public class TestActivity extends BaseActivity implements View.OnClickListener {
    Button dataBtn;
    Button permissionBtn;

    TextView dataTxt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        dataBtn=findViewById(R.id.show_data_btn);
//        permissionBtn=findViewById(R.id.permission_btn);
//        dataBtn.setOnClickListener(this);
//        permissionBtn.setOnClickListener(this);
//        dataTxt=findViewById(R.id.show_data_txt);

//
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_test_layout;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.show_data_btn:
                String str = "uid=" + SharedPreferenceUtil.getInstance(this).getValue(PersonUserBean.USER_ID_KEY, ConstantsPersonResources.SP_DEFAULT_VALUE) +
                        ";\nsessionId=" + SharedPreferenceUtil.getInstance(this).getValue(ConstantsPersonResources.SESSION_ID_KEY, ConstantsPersonResources.SESSION_ID_DEFAULT_VALUE) +
                        ";\nplatform=" + "ANDROID" +
                        ";\napp_version=" + PacageUtils.getVersionCode(this) +
                        ";\nnonce时间戳=" + System.currentTimeMillis() +
                        ";\nchannel=" + PacageUtils.getAppMetaData(this, "UMENG") +
                        ";\nc_systemVersion=" + PacageUtils.getSystemVersion() +
                        ";\nc_macAddress=" + PacageUtils.getMacAddress() +
                        ";\nc_model=" + PacageUtils.getSystemModel() +
                        ";\nc_identify(uuid)=" + PacageUtils.getDeviceId(this) +
                        ";\nc_networkType=" + NetWorkUtils.getNetworkState(this) +
                        ";\nc_phone=" + PacageUtils.getPhoneNumber(this);
                dataTxt.setText(str);
                break;
            case R.id.permission_btn:
                getPermissionRequest().request(new PermissionRequest.PermissionCallback() {
                    @Override
                    public void onSuccessful() {
                        shortToast("申请成功");
                    }

                    @Override
                    public void onFailure() {
                        shortToast("申请失败");
                    }
                },new String[]{Manifest.permission.READ_PHONE_STATE});
                break;

        }
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }


}
